/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ipercube.sample;

import com.ipercube.MeasureEvaluator;
import com.ipercube.model.ColumnModel;
import com.ipercube.model.RowModel;
import com.ipercube.DataSourceModel;
import com.ipercube.*;
import com.ipercube.impl.simple.SimpleColumnModel;
import com.ipercube.impl.simple.SimplePivotTable;
import com.ipercube.impl.simple.SimpleRowModel;

/**
 *
 * @author tartur
 */
public class Sample {

    public static void main(String[] args) {
        // create the dataModel
        DataSourceModel dataModel = new SampleDataModel();

        // build the column model
        ColumnModel colModel = new SimpleColumnModel();
        colModel.add(SampleDataModel.YEAR);

        // build the row model
        RowModel rowModel = new SimpleRowModel();
        rowModel.add(SampleDataModel.REGION);
        rowModel.add(SampleDataModel.SEMESTER);

        // create the measure evaluator
        MeasureEvaluator evaluator = new SampleMeasureEvaluator();

        // create and configure pivot
        Pivot pivot = new SimplePivotTable();

        pivot.setColumnModel(colModel);
        pivot.setRowModel(rowModel);
        pivot.setDataModel(dataModel);

        // compile pivot
        long t0 = System.currentTimeMillis();
        pivot.compile();
        System.out.println(System.currentTimeMillis() - t0);

        // show pivot result
        pivot.setMeasureEvaluator(evaluator);
        t0 = System.currentTimeMillis();
        new SampleVisualizer(pivot).show();
        System.out.println(System.currentTimeMillis() - t0);

    }
}
